package com.huixue.cn.ztej.utils.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Annotate a class for mapping a class to database table
 * 
 * @author mayanjun
 */
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Table {

	/**
	 * Table name
	 * you can use ${date} obtain a generated name with date in format 'yyyyMMdd'
	 * @return
	 */
	public String name();

	/**
	 * Some constraints except foreign keys and indexes
	 * 
	 * @return
	 */
	public String constraints() default "";

	/**
	 * The constraints of foreign key,you can use ${foreign_key_name} to obtain
	 * a generated name
	 * 
	 * @return
	 */
	public String[] foreignKeys() default {};

	/**
	 * The constraints of index,you can use ${index_name} to obtain a generated
	 * name
	 * 
	 * @return
	 */
	public String[] indexes() default {};

	/**
	 * The name of duplication of this table
	 * 
	 * @return
	 */
	public String duplication() default "";

	public boolean inherit() default true;

	public String option() default "engine=innodb auto_increment=1 default charset=utf8 default collate=utf8_general_ci";
}
